﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace MMOEng.Managers
{
    public class ResourceManager : BaseManager
    {
        private ContentManager content;
        private Dictionary<string, object> resources;

        public ResourceManager(MMOGame game)
            : base("ResourceManager",game)
        {
            content = game.Content;

            resources = new Dictionary<string, object>();
        }

        public T GetResource<T>(string contentPath)
        {
            if (resources.ContainsKey(contentPath))
                return (T)resources[contentPath];
            else
            {
                object o = content.Load<T>(contentPath);
                resources.Add(contentPath, o);
                return (T)o;
            }
        }

        public override void Update(GameTime gameTime)
        {
            //Nothing to update
        }

        public override void Draw(GameTime gameTime)
        {
            //Nothing to draw
        }

        public override void LoadContent()
        {
            //Nothing to load
        }
    }
}
